<?php 
	session_start(); 
	if (!$_SESSION["id_no"])
    {
        Header("Location: index.php");
    }
	else{
		if ($_SESSION['account_type']=='root'){
			$header="secured/header_login";
			$admin="yes";
		}
		elseif($_SESSION['account_type']=='Admin'){ 
			$header="secured/header_login";
			$admin="yes";
		}else{
			$header="header";
			$admin="no";
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ralimo System Panel</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
<link rel="stylesheet" href="css/jquery-ui-1.8.21.custom.css" type="text/css" media="screen" title="default" />
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/pro_dropline_ie.css" />
<![endif]-->
<!--  jquery core -->
<script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<!--  date picker script -->
<link rel="stylesheet" href="css/datePicker.css" type="text/css" />
<script type="text/javascript" src="js/jquery/infowindow.js"></script>
</head>
<body> 
<?php 
	include("template/$header.php");
	include("query/db_connection.php");	
	
	$city_id = $_GET['id'];
	
	$sql = "SELECT
			 city.cityname,
			 city.countryid,
			 city.zipcode,
			 country.countryname,
			 country.countrycode
			 FROM
			 city
			 INNER JOIN country ON country.countryid = city.countryid
			 WHERE
			 city.cityid='$city_id'
			 ";
	$res = mysql_query($sql);
	
	if(isset($_POST['button'])){
		$cityid    = $_POST['cityid'];
		$city_name = $_POST['city_name'];
		
		$sql_update = "UPDATE
						city
					   SET
						cityname='$city_name'
					   WHERE
					    cityid='$cityid'";
		mysql_query($sql_update);
		echo"<script type='text/javascript'>
				window.location.replace('panel.php?page=city');
			 </script>";
	}
?>
   <div class='clear'></div>
<!-- start content-outer ........................................................................................................................START -->
	<div id='content-outer'>
	<!-- start content -->
	<div id='content'>

	<!--  start page-heading -->
	<div id='page-heading'>
		<h1>Edit City</h1>
	</div>
	<!-- end page-heading -->
	
	<div id="back_affiliate" style="margin-left:1140px; width:100px;">
		<a href="panel.php?page=city"><img src="images/forms/back.png" /></a>
	</div>

	<table border='0' width='100%' cellpadding='0' cellspacing='0' id='content-table'>
	<tr>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowleft.jpg' width='20' height='300' alt='' /></th>
		<th class='topleft'></th>
		<td id='tbl-border-top'>&nbsp;</td>
		<th class='topright'></th>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowright.jpg' width='20' height='300' alt='' /></th>
	</tr>
	<tr>
		<td id='tbl-border-left'></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id='content-table-inner'>
						<!--  start step-holder -->
			
		<div style="color:#4B4B4B;font-size:13px;"><b>Change City Information:</b></div>
		<br />
		<br />
		<!--  end step-holder -->
		<!--  start table-content  -->
			<div id='table-content'>
			<form action="" method="post">
				<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
					<tr>
					<?php
						while($row = mysql_fetch_array($res)){
						echo "<tr>
								<td>
									<strong>City Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
									<input type='text' name='city_name' id='city_name' class='inp-form' value='".$row['cityname']."'/>
								</td>
							  </tr>
							  <tr>
								<td>
									<strong>Country Name:&nbsp;</strong>
									<input type='text' disabled name='country_name' id='country_name' class='inp-form' value='".$row['countryname']."' />
								</td>
							  </tr>
							  <tr>
								<td>
									<strong>Country Code:&nbsp;&nbsp;</strong>
									<input type='text' disabled name='country_code' id='country_code' class='inp-form' value='".$row['countrycode']."' />
								</td>
							  </tr>
							  <tr>
								<td>
									<strong>ZipCode:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
									<input type='text' name='zipcode' id='zipcode' class='inp-form' value='".$row['zipcode']."'/>
								</tr>
							  </tr>";
						}
					?>
						<tr>
							<td><input id="button" name="button" type="submit" class="form_update" /></td>
							<td><input type="hidden" name="cityid" value="<?php echo $city_id;?>" /></td>
						</tr>
					</tr>
				</table>
			</form>		
			<!--  start related-activities -->
			<div id="related-activities" style="margin-top:-280px;">
				<!--  start related-act-top -->
				<div id="related-act-top" style="margin-top:40px;">
				<img src="images/forms/step_bar.png" width="271" height="43" alt="" />
				</div>
				<!-- end related-act-top -->
				
				<!--  start related-act-bottom -->
				<div id="related-act-bottom">
					<!--  start related-act-inner -->
					<div id="related-act-inner">
					
						<div class="left"><a href=""><img src="images/forms/icon_edit.gif" width="21" height="21" alt="" /></a></div>
						<div class="right">
							<h5>Editing a city:</h5><br>
							<ul class="greyarrow">
								<li>First, Input the correct city name into the fields to avoid Re-editing of data.</li>
								<li>Second, Input the correct zipcode into the fields .</li>
							</ul>
						</div>
						<div class="right" style="color:red;">
							<h5>Note:</h5>
							<p style="text-indent:20px; width:250px;">The Country Name in not editable, call an IT personel when this problem occurs.</p>
							<p style="text-indent:20px; width:250px;">The Country Code in not editable, call an IT personel when this problem occurs.</p>
						</div>
						
						<div class="clear"></div>
					</div>
					<!-- end related-act-inner -->
					<div class="clear"></div>
				
				</div>
				<!-- end related-act-bottom -->
			
			</div>
			<!-- end related-activities -->

		</td>
		<td id="tbl-border-right"/>
	</tr>
	
	<tr>
		<th class='sized bottomleft'></th>
		<td id='tbl-border-bottom'>&nbsp;</td>
		<th class='sized bottomright'></th>
	</tr>
	</table>
	<div class='clear'>&nbsp;</div>

	</div>
	<!--  end content -->
	<div class='clear'>&nbsp;</div>
	</div>
	<!--  end content-outer........................................................END -->";
				
<!--  start nav-outer-repeat................................................... END -->

  <div class="clear"></div>
 
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->
<div class="clear">&nbsp;</div>    
<?php include"template/footer.php"; ?>
 </body>
</html>